#include "stdafx.h"
#include "CoreXMLHandlerManager.h"
#include "CoreXMLHandler.h"

namespace ExamSystem
{

    CCoreXMLHandlerManager::CCoreXMLHandlerManager(void)
    {

    }

    CCoreXMLHandlerManager::~CCoreXMLHandlerManager(void)
    {

    }

    CCoreXMLHandler * CCoreXMLHandlerManager::CreateHandler(void)
    {
        return new CCoreXMLHandler(this);
    }

    void CCoreXMLHandlerManager::RegisterStanzaHandler(const std::string &type, CStanzaHandler *handler)
    {
        m_registeredHandlers.insert(std::make_pair(type, handler));
    }

    void CCoreXMLHandlerManager::GetStanzaHandler(const std::string &type, std::vector<CStanzaHandler *> &handlers) const
    {
        std::multimap<std::string, CStanzaHandler *>::const_iterator it = m_registeredHandlers.lower_bound(type);
        std::multimap<std::string, CStanzaHandler *>::const_iterator itEnd = m_registeredHandlers.upper_bound(type);
        for (; it != itEnd; it++)
            handlers.push_back(it->second);
    }

}